<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>注册</title>
    <link rel="stylesheet" href="css/style.css" />
<body>

<div class="register-container">
    <h1>安时利医疗有限公司</h1>

    <div class="connect">
        <p>Link the world. Share to world.</p>
    </div>

        <div>
            <input type="text" id="uname" placeholder="您的用户名"/>
        </div><label></label>
        <div>
            <input type="password" id="upass" placeholder="输入密码" />
        </div>
        <span></span>
        <div>
            <button id="re">注 册</button>
        </div>

    <a href="jump">
        <button type="button" class="register-tis">已经有账号？</button>
    </a>

</div>


<script src="js/jquery.min.js"></script>
<script src="js/common.js"></script>
<!--背景图片自动更换-->
<script src="js/supersized.3.2.7.min.js"></script>
<script src="js/supersized-init.js"></script>
<!--表单验证-->
<script src="js/jquery.validate.min.js?var1.14.0"></script>

</body>

<script type="text/javascript">
    $(document).ready(function () {
        //移出用户名框时对用户名进行唯一性校验
        $("#uname").bind('blur',function(){

            if("" == $("#uname").val()){
                $("label").html("用户名不能为空");
            }else {
                $.ajax({
                    url:"uniqueName",
                    data:{'uname':$("#uname").val()},
                    type:"post",
                    success:function (result) {
                        if(result.result == '0002'){
                            $("label").html("用户名已存在")
                        }else{
                            $("label").html("用户名可用")
                        }
                    }
                });
            }
        });
    });

    $("#re").click(function(){
        if("用户名可用" == $("label").html()){
            if("" == $("#upass")){
                alert("密码不能为空");
            }else {
                $.ajax({
                    url: "regist",
                    type: "post",
                    data: {"uname":$("#uname").val(),"upass":$("#upass").val()},
                    success: function (result) {
                        if(result.result == '0000'){
                            alert("注册成功,去登录");
                            window.location.href="jump";
                        }else{
                            alert("注册失败!");
                        }
                    }
                });
            }
         }
    });

</script>
</html>

